<!DOCTYPE html>
<html lang="en">
<head><meta name="generator" content="Hexo 3.9.0">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="GeekZhang的博客">
    <meta name="keyword" content="GeekZhang">
    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>
        
        web开发 - GeekZhang的博客 | GeekZhang&#39;s Blog
        
    </title>

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/aircloud.css">
    <link rel="stylesheet" href="/css/gitment.css">
    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_pl6z7sid89qkt9.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
</head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> 不乱于心，不困于情。不畏将来，不念过往。如此，安好。 </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>GeekZhang</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/archive">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li >
                <a href="/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
        <div id="toc" class="toc-article">
    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#分享内容"><span class="toc-text">分享内容</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#一、web开发"><span class="toc-text">一、web开发</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#BS开发发展历程："><span class="toc-text">BS开发发展历程：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MVC"><span class="toc-text">MVC</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#额外的一些补充"><span class="toc-text">额外的一些补充</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#二、Spring、SpringMVC、SpringBoot常用注解"><span class="toc-text">二、Spring、SpringMVC、SpringBoot常用注解</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#三、Maven、Mybatis、SpringBoot"><span class="toc-text">三、Maven、Mybatis、SpringBoot</span></a></li></ol></li></ol>
</div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> 不乱于心，不困于情。不畏将来，不念过往。如此，安好。 </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        


<div class="post-container">
    <div class="post-title">
        web开发
    </div>

    <div class="post-meta">
        <span class="attr">发布于：<span>2018-10-14 16:20:00</span></span>
        
        <span class="attr">标签：/
        
        <a class="tag" href="/tags/#java" title="java">java</a>
        <span>/</span>
        
        
        </span>
        <span class="attr">访问：<span id="busuanzi_value_page_pv"></span>
</span>
</span>
    </div>
    <div class="post-content no-indent">
        <h1 id="分享内容"><a href="#分享内容" class="headerlink" title="分享内容"></a>分享内容</h1><h2 id="一、web开发"><a href="#一、web开发" class="headerlink" title="一、web开发"></a><strong>一、web开发</strong></h2><p>CS，即Client/Server(客户机/服务器)</p>
<p>BS，即Browser/Server(浏览器/服务器)</p>
<h3 id="BS开发发展历程："><a href="#BS开发发展历程：" class="headerlink" title="BS开发发展历程："></a><strong>BS开发发展历程：</strong></h3><a id="more"></a>
<p>&emsp;&emsp;静态 Web页面：由文本编辑器直接编辑并生成静态的HTML页面，如果要修改Web页面的内容，就需要再次编辑HTML源文件，早期的互联网Web页面就是静态的 </p>
<p>&emsp;&emsp;ASP/JSP/PHP：ASP是微软推出的用VBScript脚本编程的Web开发技术，而JSP用Java来编写脚本，PHP本身则是开源的脚本语言。</p>
<p>&emsp;&emsp;MVC：为了解决直接用脚本语言嵌入HTML导致的可维护性差的问题，Web应用也引入了Model-View-Controller的模式，来简化Web开发。Java的SSM、SSH框架。</p>
<p>&emsp;&emsp;RESTful架构，EST全称是Representational State Transfer，中文意思是表述性状态转移。GET、POST、DELETE、PUT四种请求方式对应不同的功能，GET用来获取资源，POST用来创建资源，DELETE删除资源，PUT更新资源。举个例子： 假设一个网站网址为：<a href="http://www.a.com" target="_blank" rel="noopener">www.a.com</a>, 如果我想获取用户名为“john”的用户信息，那么我请求的url应该为：“<a href="http://www.a.com/userInfo/john”" target="_blank" rel="noopener">www.a.com/userInfo/john”</a>, 请求方式为GET，对应的后端接口为“<a href="http://www.a.com/userInfo/{username}”" target="_blank" rel="noopener">www.a.com/userInfo/{username}”</a> 。</p>
<h3 id="MVC"><a href="#MVC" class="headerlink" title="MVC"></a><strong>MVC</strong></h3><p>&emsp;&emsp;MVC是一种经典的设计模式，Model-View-Controller，即模型-视图-控制器。M主要负责数据与模型，V主要负责显示，C主要负责交互与业务。<br>如用户发送一个HTTP请求，此时该请求首先会进入控制器，然后控制器去获取数据并将其封装为模型，最后将模型传递到视图中进行展现。</p>
<p><img src="/2018/10/14/web开发/1.png" alt="1.png"></p>
<p>MVC:</p>
<p><img src="/2018/10/14/web开发/mvc原版.png" alt="mvc原版"></p>
<p>改进：</p>
<p><img src="/2018/10/14/web开发/MVC改进.png" alt="mvc改进"></p>
<h3 id="额外的一些补充"><a href="#额外的一些补充" class="headerlink" title="额外的一些补充"></a>额外的一些补充</h3><p><strong>XML</strong>(Extensible Markup Language),可扩展标记语言,是一种标记语言，很类似 HTML,设计宗旨是传输数据，而非显示数据，标签没有被预定义，需要自行定义标签。<br><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">note</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">to</span>&gt;</span>George<span class="tag">&lt;/<span class="name">to</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">from</span>&gt;</span>John<span class="tag">&lt;/<span class="name">from</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">heading</span>&gt;</span>Reminder<span class="tag">&lt;/<span class="name">heading</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">body</span>&gt;</span>Don't forget the meeting!<span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">note</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p><strong>JSON</strong>(JavaScript Object Notation, JS 对象简谱) 是一种轻量级的数据交换格式，对象表示为键值对、数据由逗号分隔、花括号保存对象、方括号保存数组。<br><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"username"</span>:<span class="string">"john"</span>,</span><br><span class="line">    <span class="attr">"password"</span>:<span class="string">"123"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[&#123;</span><br><span class="line">   <span class="attr">"username"</span>:<span class="string">"john"</span>,</span><br><span class="line">   <span class="attr">"password"</span>:<span class="string">"123"</span></span><br><span class="line">&#125;,</span><br><span class="line">&#123;</span><br><span class="line">    <span class="attr">"username"</span>:<span class="string">"tom"</span>,</span><br><span class="line">    <span class="attr">"password"</span>:<span class="string">"456"</span></span><br><span class="line">&#125;]</span><br></pre></td></tr></table></figure>
<p><strong>SSH框架，SSM框架</strong> </p>
<p>Spring，它是一个容器框架，用来装javabean（java对象），中间层框架（万能胶）可以起一个连接作用，比如说把Struts和hibernate粘合在一起运用。简单来说，Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。</p>
<p>Struts,SpringMVC</p>
<p>Hibernate,Mybatis</p>
<p>&emsp;&emsp;MyBatis 是一款优秀的持久层框架，它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息，将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。</p>
<h2 id="二、Spring、SpringMVC、SpringBoot常用注解"><a href="#二、Spring、SpringMVC、SpringBoot常用注解" class="headerlink" title="二、Spring、SpringMVC、SpringBoot常用注解"></a><strong>二、Spring、SpringMVC、SpringBoot常用注解</strong></h2><p>&emsp;&emsp;注解（Annotation），也叫元数据。一种代码级别的说明。它是JDK1.5及以后版本引入的一个特性，与类、接口、枚举是在同一个层次。它可以声明在包、类、字段、方法、局部变量、方法参数等的前面，用来对这些元素进行说明，注释。</p>
<p>&emsp;&emsp;元注解,是可以注解到注解上的注解,有 @Retention、@Documented、@Target、@Inherited、@Repeatable、@Native 6 种。</p>
<p>&emsp;&emsp;Java中的注解：@Override 提示子类要复写父类中被 @Override 修饰的方法</p>
<p><img src="/2018/10/14/web开发/注解.png" alt="注解"></p>
<p><strong>@Bean</strong></p>
<p>&emsp;&emsp; Bean简单的讲，就一个类。在类上加上@Bean注解，表示交给Spring去管理。</p>
<p><strong>@Autowired</strong></p>
<p>&emsp;&emsp; 翻译：自动装配。默认按类型匹配的方式，在容器查找匹配的Bean，当有且仅有一个匹配的Bean时，Spring将其注入@Autowired标注的变量中。</p>
<figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">My</span> &#123;</span></span><br><span class="line">    <span class="keyword">private</span> Test test = <span class="keyword">new</span> Test();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">---------------对比----------------</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">My</span>&#123;</span></span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> Test test;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>@Controller</strong></p>
<p>&emsp;&emsp;表现层的Bean</p>
<p><strong>@ResponseBody</strong></p>
<p>&emsp;&emsp;该注解用于将Controller的方法返回的对象，通过适当的转换为指定格式后，写入到Response对象的body数据区。适用于返回的数据不是html标签的页面，而是其他某种格式的数据时（如json、xml等）使用；</p>
<p><strong>@RequestMapping</strong></p>
<p>&emsp;&emsp;是一个用来处理请求地址映射的注解。</p>
<p>&emsp;&emsp;value：指定请求的实际地址</p>
<p>&emsp;&emsp;method：指定请求的method类型， GET、POST、PUT、DELETE等；</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Controller</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestController</span> </span>&#123;</span><br><span class="line">	</span><br><span class="line">	<span class="meta">@Autowired</span></span><br><span class="line">	MyService myService;</span><br><span class="line">	</span><br><span class="line">	<span class="meta">@RequestMapping</span>(value= <span class="string">"/"</span>, method = RequestMethod.GET)</span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span>  <span class="title">doSomething</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		<span class="comment">//doSomething;</span></span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>@Service</strong></p>
<p>&emsp;&emsp;业务层的Bean</p>
<h2 id="三、Maven、Mybatis、SpringBoot"><a href="#三、Maven、Mybatis、SpringBoot" class="headerlink" title="三、Maven、Mybatis、SpringBoot"></a><strong>三、Maven、Mybatis、SpringBoot</strong></h2><p><strong>Maven</strong></p>
<p>Java三大构建工具：Ant、Maven和Gradle。</p>
<p>Maven的主要功能主要分为5点，分别是依赖管理系统、多模块构建、一致的项目结构、一致的构建模型和插件机制。</p>
<p>常用命令：</p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">编译：mvn compile　 　 <span class="comment">--src/main/java目录java源码编译生成class （target目录下）</span></span><br><span class="line">测试：mvn test　　　   <span class="comment">--src/test/java 目录编译</span></span><br><span class="line">清理：mvn clean　　　  <span class="comment">--删除target目录，也就是将class文件等删除</span></span><br><span class="line">打包：mvn <span class="keyword">package</span>　   <span class="title">--生成压缩文件：java项目#jar包；web项目#war包，也是放在target目录下</span></span><br><span class="line">安装：mvn install　　  <span class="comment">--将压缩文件(jar或者war)上传到本地仓库</span></span><br><span class="line">发布：mvn deploy      <span class="comment">--将压缩文件上传私服</span></span><br></pre></td></tr></table></figure>
<p>资料：<a href="https://www.cnblogs.com/whgk/p/7112560.html" target="_blank" rel="noopener">https://www.cnblogs.com/whgk/p/7112560.html</a></p>
<p><strong>Mybatis</strong></p>
<p>参考资料：<br><a href="http://www.mybatis.org/mybatis-3/zh/index.html" target="_blank" rel="noopener">http://www.mybatis.org/mybatis-3/zh/index.html</a></p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">mapper</span> <span class="meta-keyword">PUBLIC</span> <span class="meta-string">"-//mybatis.org//DTD Mapper 3.0//EN"</span> <span class="meta-string">"http://mybatis.org/dtd/mybatis-3-mapper.dtd"</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p><strong>SpringBoot</strong></p>
<blockquote>
<p>&emsp;&emsp;Spring Boot is the starting point for building all Spring-based applications. Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring.</p>
</blockquote>
<blockquote>
<p>&emsp;&emsp;Spring Bug是构建基于Spring的应用程序的起点。Spring Bug的设计是为了让你尽可能快地用最小的配置启动起来你的Spring程序。</p>
</blockquote>

        
        <br />
        <div id="comment-container">
        </div>
        <div id="disqus_thread"></div>

        <div id="lv-container">
        </div>

    </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        
        <li>
            <a target="_blank"  href="https://github.com/geekzhi">
                            <span class="fa-stack fa-lg">
                                <i class="iconfont icon-github"></i>
                            </span>
            </a>
        </li>
        

        

    </ul>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a href="https://hexo.io/">Hexo</a>  Theme <a href="https://github.com/aircloud/hexo-theme-aircloud">AirCloud</a></p>
</footer>




</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/"
    window.isPost = true
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="/js/index.js"></script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




</html>
